﻿namespace MicroCloud.Systems.Entities
{
    /// <summary>
    /// 实体类：文件基类
    /// </summary>
    /// <typeparam name="TKey">文件简介主键类型</typeparam>
    /// <typeparam name="TUserKey">用户实体主键类型</typeparam>
    public abstract class FileBase<TKey, TUserKey> : EntityBase<TKey>, ICreationAudited<TUserKey>, IUpdateAudited<TUserKey>
        where TKey : struct, IEquatable<TKey>
        where TUserKey : struct, IEquatable<TUserKey>
    {
        /// <summary>
        /// 获取或设置 文件名称
        /// </summary>
        [DisplayName("文件名称")]
        [StringSize(StringSizeType.Name), Required]
        public string FileName { get; set; }

        /// <summary>
        /// 获取或设置 文件扩展名
        /// </summary>
        [StringSize(StringSizeType.Key), Required]
        [DisplayName("文件扩展名")]
        public string FileExtension { get; set; }

        /// <summary>
        /// 获取或设置 文件大小(bytes)
        /// </summary>
        [DisplayName("文件大小(bytes)")]
        public long Size { get; set; }

        /// <summary>
        /// 获取或设置 文件序列化名称
        /// </summary>
        [StringSize(StringSizeType.Name), Required]
        [DisplayName("文件序列化名称")]
        public string SerializedName { get; set; }

        /// <summary>
        /// 获取或设置 文件SHA1值
        /// </summary>
        [StringSize(StringSizeType.Name), Required]
        [DisplayName("文件SHA1值")]
        public string SHA1 { get; set; }

        /// <summary>
        /// 获取或设置 文件MD5值
        /// </summary>
        [StringSize(StringSizeType.Name), Required]
        [DisplayName("文件MD5值")]
        public string MD5 { get; set; }

        /// <summary>
        /// 获取或设置 物理存储路径
        /// </summary>
        [StringSize(StringSizeType.Name), Required]
        [DisplayName("物理存储路径")]
        public string PhysicalPath { get; set; }

        /// <summary>
        /// 获取或设置 文件请求路径
        /// </summary>
        [StringSize(StringSizeType.Name)]
        [DisplayName("文件请求路径")]
        public string RequestPath { get; set; }

        /// <summary>
        /// 获取或设置 文件版本
        /// </summary>
        [DisplayName("文件版本")]
        public long Version { get; set; }


        #region ICreationAudited<TUserKey>
        /// <summary>
        /// 获取或设置 创建者编号
        /// </summary>
        [Column("CreatorId")]
        [DisplayName("创建者编号")]
        public TUserKey? CreatorId { get; set; }

        /// <summary>
        /// 获取或设置 创建时间
        /// </summary>
        [Column("CreatedTime")]
        [DisplayName("创建时间")]
        public DateTime CreatedTime { get; set; }
        #endregion

        #region IUpdateAudited<TUserKey>        
        /// <summary>
        /// 获取或设置 更新者编号
        /// </summary>
        [DisplayName("更新者编号")]
        public TUserKey? UpdaterId { get; set; }

        /// <summary>
        /// 获取或设置 更新时间
        /// </summary>
        [DisplayName("更新时间")]
        public DateTime? UpdatedTime { get; set; }
        #endregion
    }
}
